package com.hirsi.module.auth.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.hirsi.core.annotation.IgnoreAccessToken;
import com.hirsi.module.auth.service.AuthService;
import com.hirsi.module.auth.vo.param.AccountLoginParam;
import com.hirsi.module.auth.vo.result.CaptchaResult;
import com.hirsi.module.auth.vo.result.TokenResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "授权登录相关接口")
@ApiSupport(order = 1)
@RestController
@RequestMapping("v1/auth")
public class AuthController {

    @Autowired
    private AuthService authService;

    @IgnoreAccessToken
    @ApiOperation("获取验证码图片")
    @ApiOperationSupport(order = 1)
    @GetMapping(value = "captcha")
    public CaptchaResult captcha() {
        return authService.captcha();
    }

    @IgnoreAccessToken
    @ApiOperation("账号密码登录")
    @ApiOperationSupport(order = 1)
    @PostMapping(value = "account_login")
    public TokenResult accountLogin(@RequestBody AccountLoginParam param) {
        return authService.accountLogin(param);
    }
}
